# Contributor: Ian Bashford <ianbashford@gmail.com>
# Maintainer: Ian Bashford <ianbashford@gmail.com>
pkgname=xe-guest-utilities
pkgver=7.30.0
pkgrel=6
pkgdesc="XenServer guest tools"
url="https://github.com/xenserver/xe-guest-utilities"
arch="x86 x86_64 aarch64"
license="BSD-2-Clause"
makedepends="go udev"
subpackages="$pkgname-udev:udev:noarch $pkgname-openrc"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/xenserver/xe-guest-utilities/archive/v$pkgver.tar.gz
	$pkgname.initd
	detect_distribution.patch
	"

build() {
	make
}

package() {
	mkdir -p "$pkgdir"
	cp -ar "$builddir/build/stage/usr/" "$pkgdir/"
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/"$pkgname"
}

udev() {
	depends=""
	pkgdesc="udev rules for CPU hotplugging when running as Xen DomU"
	install_if="$pkgname=$pkgver-r$pkgrel udev"

	mkdir -p "$subpkgdir"/usr/lib/udev/rules.d
	install -Dm644 "$builddir"/build/stage/etc/udev/rules.d/*.rules -t "$subpkgdir"/usr/lib/udev/rules.d
}

sha512sums="7bb4692f6d19208b0c94269edb4af3f24d19077bca547bc88f1d7b3dc0a91f43b1c41d81701808125c0836b305f2c8b4f38407fa0a1bf1111f7ee49e4787a459  xe-guest-utilities-7.30.0.tar.gz
3e898b473f6e71ecc5b820717df0a460b31756b68f4bb9bf454df39f430e64ca5e33582c03bfea044d93f49937883fe9b6807c31dee72307750de670bfca8bcd  xe-guest-utilities.initd
ac3532854cd38cea30e1ea31f72c4852babf7464939144c05b3c60c3859ff4e073a634f53b863b947187145c291127b5c4c11174a39c9bae2a248b24036fa177  detect_distribution.patch"
